package com.atguigu.tingshu.account.service;

import com.atguigu.tingshu.model.account.UserAccount;
import com.atguigu.tingshu.model.account.UserAccountDetail;
import com.atguigu.tingshu.vo.account.AccountDeductVo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;

import java.math.BigDecimal;

public interface UserAccountService extends IService<UserAccount> {


    void addUserAccount(Long userId);


    /**
     * 获取账户可用余额
     * @param userId
     * @return
     */
    BigDecimal getAvailableAmount(Long userId);

    /**
     * 根据用户Id 获取到可用余额对象
     * @param userId
     * @return
     */
    UserAccount getUserAccountByUserId(Long userId);

    int checkAndDeduct(AccountDeductVo accountDeductVo);

    void add(Long userId, BigDecimal amount, String orderNo, String tradeType, String title);

    IPage<UserAccountDetail> findUserRechargePage(Page<UserAccountDetail> pageParam, Long userId);

    IPage<UserAccountDetail> findUserConsumePage(Page<UserAccountDetail> pageParam, Long userId);
}
